<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>编辑专利</title>
    <#include "layout/import_js.ftl" />
    <#include "layout/import_css.ftl" />
    <script>
        $(() => {
            $("#edit-patent").on('click', function () {
                let form = new FormData(document.getElementById("form-patent"));
                $.ajax({
                    url: '/patent/edit',
                    method: 'post',
                    data: form,
                    processData: false, //禁止序列化data
                    contentType: false, //避免JQuery对contentType做操作
                    success: function (res) {
                        if (res.code == 0) {
                            $('#alertModal').modal('show')
                        } else {
                            console.log(res);
                        }
                    },
                    error: function (err) {
                        console.log(err);
                    }
                })
            })

        })
    </script>
</head>
<body>
<#include "layout/header.ftl"/>
<#include "layout/sidebar.ftl"/>

<div class="container">
    <div class="raw">
        <div class="col-sm-6 col-sm-offset-3">
            <form action="/patent/edit" id="form-patent" method="POST" enctype="multipart/form-data" class="form-horizontal">
                <input type="hidden" name="id" value="${entity.id}">
                <div class="form-group">
                    <label>编号</label>
                    <input type="text" class="form-control" value="${entity.number!''}" name="number"
                           placeholder=" ">
                </div>
                <div class="form-group">
                    <label>名称</label>
                    <input type="text" class="form-control" value="${entity.name?default('')}" name="name" placeholder=" ">
                </div>
                <div class="form-group">
                    <label>项目名</label>
                    <input type="text" class="form-control" value="${entity.projectName?default('')}" name="projectName"
                           placeholder=" ">
                </div>
                <div class="form-group">
                    <label>作者</label>
                    <input type="text" class="form-control" value="${entity.authors?default('')}" name="authors" placeholder=" ">
                </div>
                <div class="form-group">
                    <label>发表日期</label>
                    <input type="date" class="form-control" value="${entity.applyDate?string('yyyy-MM-dd')}" name="applyDate">
                </div>
                <div class="form-group">
                    <label>发表日期</label>
                    <input type="date" class="form-control" value="${entity.pastDate?string('yyyy-MM-dd')}" name="pastDate">
                </div>
                <div class="form-group">
                    <label for="exampleInputFile">上传文件</label>
                    <div>
                        当前文件:
                        <a href="/upload-attachments/patent/${entity.attachment!''}">${entity.attachment!''}</a>
                    </div>
                    <input type="file" name="file" id="attachment" accept=".jpg,
                    .jpeg,.png,.doc,
                    .docx,.pdf,
                    .ppt,.pptx,.xlsx">
                    <input type="hidden" name="attachment" value="${entity.attachment?default('')}">
                    <p class="help-block">支持pdf、word、excel、png、jpeg等类型</p>
                </div>

                <div class="form-group">
                    <div class="col-sm-6 col-sm-offset-3">
                        <button type="button" class="btn btn-success" id="edit-patent" class="btn btn-success">保存
                        </button>
                        <button class="btn btn-info">取消</button>
                        <button type="reset" class="btn btn-warning">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<#include "layout/alert.ftl"/>

<#include "layout/footer.ftl"/>
</body>
</html>